<template>
	<view class="indx mains">
		<u--text :text="addAccountType" bold color="#ff557f" size="18px"></u--text>
		<view>
			<u--form labelPosition="left" :model="moneyType" ref="uForm">
				<u-form-item label="父节点" prop="moneyType.parentId" ref="item1" label-width="60px">
					<u--input v-model="moneyType.parentId" border="none"></u--input>
				</u-form-item>
				<u-form-item label="类别" prop="moneyType.typeName" ref="item1" label-width="60px">
					<u--input v-model="moneyType.typeName" border="none"></u--input>
				</u-form-item>
				<u-form-item label="金额" prop="moneyType.money" ref="item1" label-width="60px">
					<u--input v-model="moneyType.money" border="none"></u--input>
				</u-form-item>
			</u--form>
		</view>
		<view>
			<u-button color="#ff557f" :plain="true" size="mini" text="确认" style="width: 40px;"
				@click="confirmAdd"></u-button>
		</view>
	</view>
</template>

<script>
	import moneyService from '../../dbservice/moneyService';
	export default {
		data() {
			return {
				addAccountType: '',
				moneyType: {
					parentId: '0',
					typeName: '',
					money: '',
					status: '1'
				},
				showMainAccountConfirm: true,
				mainAccountList: [{
					key: 1,
					value: "支付宝"
				}, {
					key: 2,
					value: "银行"
				}]
			}
		},
		onLoad(option) {
			this.addAccountType = option.type;
		},
		onShow() {},
		onReady() {},
		methods: {
			mainAccountConfirm(e) {
				console.log(e);
			},
			async confirmAdd() {
				await moneyService.insertdata(this.moneyType.parentId, this.moneyType.typeName, this.moneyType.money,
					this.moneyType.status).then(res => console.log(res)).then(this.goBack()).catch(error => console
					.log(error));
			},
			goBack() {
				uni.switchTab({
					url: "/pages/index/index"
				});
			}
		}
	}
</script>

<style lang="scss">
	.mains {
		padding-left: 6%;
	}

	.indx {
		padding-top: 20px;
		background-color: #FAACA8;
		background-image: linear-gradient(19deg, #FAACA8 0%, #DDD6F3 100%);

		// background-color: #FF9A8B;
		// background-image: linear-gradient(90deg, #FF9A8B 0%, #FF6A88 55%, #FF99AC 100%);

		height: 100%;
		width: 100%;
	}
</style>